<?php
/**
 * Created by PhpStorm
 * User: shen.zk
 * Date: 2023/9/14
 * Time: 10:18
 * Comment: ''
 */

namespace App\Repository;

use  App\Models\OpenPlatform;

class OpenPlatformRepo extends BaseRepo
{

    /**
     * 根据平台商户号获取信息
     * @param string $platform_no
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
     * @author shen.zk
     * @date 2023-09-14 10:20
     */
    public function getByPlatformNo(string $platform_no)
    {
        return OpenPlatform::query()->where('platform_no', $platform_no)->first();
    }

    /**
     * 根据平台号获取信息
     * @param string $platform_no
     * @return array
     * Author:xsc
     * Time:2023/10/13 10:06
     */
    public function getInfoByPlatformNo(string $platform_no)
    {
        $res = OpenPlatform::query()->where('platform_no', $platform_no)->first();
        return $res ? $res->toArray() : [];
    }

    /**
     * 根据id获取信息
     * @param int $id
     * @return array
     * Author:xsc
     * Time:2023/11/21 10:05
     */
    public function getInfo(int $id)
    {
        $res = OpenPlatform::query()->where('id', $id)->first();
        return $res ? $res->toArray() : [];
    }

}
